package no.uib.hplims.tools.columngenerators;

import no.uib.hplims.models.Peptide;

import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Table.ColumnGenerator;

public class NumberOfBlastHitsColumnGenerator implements ColumnGenerator {

	private static final long serialVersionUID = -4868045250980463087L;

	public Object generateCell(Table source, Object itemId, Object columnId) {
		Peptide p = (Peptide) itemId;
		int numBlastHits = p.getNumBlastHits();

		Label l = new Label("" + numBlastHits);
		if (numBlastHits == 1) {
			l.setStyleName("minisuccess");
		} else if (numBlastHits > 1) {
			l.setStyleName("miniwarning");
		} else {
			l.setStyleName("minierror");
		}
		return l;
	}

}
